﻿using System;

namespace UniRx.Operators
{
	// Token: 0x02000248 RID: 584
	internal class AsObservableObservable<T> : OperatorObservableBase<T>
	{
		// Token: 0x06000D7D RID: 3453 RVA: 0x000401D0 File Offset: 0x0003E5D0
		public AsObservableObservable(IObservable<T> source) : base(source.IsRequiredSubscribeOnCurrentThread<T>())
		{
			this.source = source;
		}

		// Token: 0x06000D7E RID: 3454 RVA: 0x000401E5 File Offset: 0x0003E5E5
		protected override IDisposable SubscribeCore(IObserver<T> observer, IDisposable cancel)
		{
			return this.source.Subscribe(new AsObservableObservable<T>.AsObservable(observer, cancel));
		}

		// Token: 0x040007A7 RID: 1959
		private readonly IObservable<T> source;

		// Token: 0x02000249 RID: 585
		private class AsObservable : OperatorObserverBase<T, T>
		{
			// Token: 0x06000D7F RID: 3455 RVA: 0x000401F9 File Offset: 0x0003E5F9
			public AsObservable(IObserver<T> observer, IDisposable cancel) : base(observer, cancel)
			{
			}

			// Token: 0x06000D80 RID: 3456 RVA: 0x00040203 File Offset: 0x0003E603
			public override void OnNext(T value)
			{
				this.observer.OnNext(value);
			}

			// Token: 0x06000D81 RID: 3457 RVA: 0x00040214 File Offset: 0x0003E614
			public override void OnError(Exception error)
			{
				try
				{
					this.observer.OnError(error);
				}
				finally
				{
					base.Dispose();
				}
			}

			// Token: 0x06000D82 RID: 3458 RVA: 0x0004024C File Offset: 0x0003E64C
			public override void OnCompleted()
			{
				try
				{
					this.observer.OnCompleted();
				}
				finally
				{
					base.Dispose();
				}
			}
		}
	}
}
